<!DOCTYPE html>
<html lang="zh-Hans-CN">
<head>
  <% include("/include/header3.html",{"title":"登录"}){} %>
</head>
<body>
<div id="app" class="w-full fulled-height flex-center">

  <div class="flex flex-col flex-col-center-center">
    <div class="flex flex-row flex-row-center-center mb-n10">
      <div class="mr-20"><img src="images/logo.png" style="height: 80px"></div>
      <div class="text-size-34 font-bold tracking-wide">后台管理系统</div>
    </div>
    <t-card shadow bordered>
      <div class="px-n5 py-n10">
        <t-form ref="formRef" :data="formData" :colon="true" :label-width="0" size="large" @submit="onSubmit" class="w-80">
          <t-form-item name="account">
            <t-input v-model="formData.account" size="large" clearable placeholder="请输入账户名">
              <template #prefix-icon>
                <i class="layui-icon layui-icon-username"></i>
              </template>
            </t-input>
          </t-form-item>
          <t-form-item name="password">
            <t-input v-model="formData.password" type="password" size="large" clearable placeholder="请输入密码">
              <template #prefix-icon>
                <i class="layui-icon layui-icon-password"></i>
              </template>
            </t-input>
          </t-form-item>
          <t-form-item>
            <t-button :loading="loading" theme="primary" type="submit" size="large" block>登录</t-button>
          </t-form-item>
        </t-form>
      </div>
    </t-card>
  </div>
</div>
<script>


  if (window !== top) top.location.replace(location.href);
  let notice;
  layui.use(['notice'], function () {
    notice = layui.notice;
  })
  setupVue("#app", {
    setup() {
      const loading = Vue.ref(false);
      const formRef = Vue.ref();
      const formData = Vue.ref({
        account: 'admin',
        password: 'admin',
      })

      const onSubmit = ({ validateResult, firstError }) => {
        if (validateResult === true) {
          loading.value = true;
          req(axiosPost, "anon/login", formData, (res) => {
            if (res.code === 200) {
              window.location.href = BASEURL + "home"
            } else {
              $baseMsg(res.msg);
              loading.value = false;
            }
          })
        } else {
          console.log('Validate Errors: ', firstError, validateResult);
          TDesign.MessagePlugin.warning(firstError);
        }
      };

      return {
        formRef, formData, onSubmit,
        loading,
      }
    },
  });
</script>


</body>
</html>
